package com.wei.controller;


import com.wei.pojo.BaseResult;
import com.wei.pojo.Product;
import com.wei.service.ProductService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/product")
@CrossOrigin
public class ProductController {

    @Autowired
    ProductService productService;

    @RequestMapping("/findAll")
    public BaseResult findAll(@RequestParam("page")Integer page, @RequestParam("size")Integer size){
        return productService.findAll(page,size);
    }
@RequestMapping("/findById")
    Product findById( Integer id){
        return productService.findById(id);
    };
@RequestMapping("/deleteById")
    int deletrById(Integer id){
        return productService.deletrById(id);
    };

@RequestMapping("/updateOrSave")
    int saveOrUpdate(@RequestBody Product product){
    return productService.saveOrUpdate(product);
};

}
